<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix='sec' uri='http://www.springframework.org/security/tags'%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<script type="text/javascript" src="scripts/boot.js"></script>
<style type="text/css">
.item{
	width: 90px;
	display: inline-block;
	margin-left: 5px;
}
</style>
</head>
<body style="border: 0px; margin: 0px; padding: 0px;width: 100%;height: 100%">
	<div class="mini-toolbar" style="border-bottom:0;padding:0px;">
	<div id="splitter1" class="mini-splitter" vertical="true" style="width:100%;height: 70px;min-width: 800px">
		<div class="splitterDiv" style="border: none;">
			<table style="width:100%;">
				<tr>
					<td style="width:30%;">
		        		<span class="item">创建开始时间：</span>
		                <input id="create_time" emptyText="请选择..." class="mini-datepicker" style="width:160px;" format="yyyy-MM-dd HH:mm:ss" timeFormat="HH:mm:ss" showTime="true" allowInput="false"/>
		        	</td>
					<td style="width:30%;">
		        		<span class="item">创建截止时间：</span>
		                <input id="end_time" emptyText="请选择..." class="mini-datepicker" style="width:160px;" format="yyyy-MM-dd HH:mm:ss" timeFormat="HH:mm:ss" showTime="true" allowInput="false"/>
		        	</td>
					<td style="width:30%;">
		        		<span class="item">编号：</span>
		                <input id="serialNum" emptyText="请输入编号" class="mini-textbox" style="width:160px;" />
		        	</td>
		        	<td style="display: inline-block;"><a class="mini-button" iconCls="icon-search" onclick="search()">查询</a></td>
				</tr>
				<tr>
				    <td style="width:30%;">
		                <span class="item">更新开始时间：</span>
				    	<input id="u_stime" class="mini-datepicker" emptyText="请选择..." style="width:160px;" format="yyyy-MM-dd HH:mm:ss" timeFormat="HH:mm:ss" showTime="true" allowInput="false"/>
		            </td>
					<td style="width:30%;">
		                <span class="item">更新截止时间：</span>
				    	<input id="u_etime" class="mini-datepicker" emptyText="请选择..." style="width:160px;" format="yyyy-MM-dd HH:mm:ss" timeFormat="HH:mm:ss" showTime="true" allowInput="false"/>
		            </td>
					<td>
		        		<span class="item">话务类别：</span>
		        		<input id="s_category" class="mini-combobox" style="width:160px;" textField="keyValue" valueField="keyName" emptyText="请选择..."
   				 		url="dictionary_cm_key_val_view.do?typeName=CALL_TASK_TYPE" allowInput="false" showNullItem="true" nullItemText="全部"/>
		        	</td>
		        	<td style="display: inline-block;"><a href="javascript:showHq();">更多</a></td>
				</tr>
			</table>
		</div>
		<div visible="false" class="splitterDiv" style="border: none;">
			<table style="width:100%;">
				<tr>
				    <td style="width:30%;">
		        		<span class="item">相关手机号：</span>
		        		<input id="s_relatedPhone" emptyText="请输入手机号码" class="mini-textbox" style="width:160px;"/>
		        	</td>
					<td style="width:30%;">
		        		<span class="item">外线号码：</span>
		        		<input id="s_outsideNum" emptyText="请输入外线号码" class="mini-textbox" style="width:160px;"/>
		        	</td>
		            <td style="width:30%;"></td>
		            <td style="display: inline-block;"><a href="javascript:hideHq();">收起</a></td>
				</tr>
			</table>
		</div>
	</div>
	</div>
	<div id="toolbar1" class="mini-toolbar" style="padding:2px;">
	    <table style="width:100%;">
	        <tr>
		        <td style="width:100%;">
		        	<sec:authorize url='/call_allocate_add.do'>
		            <a class="mini-button" iconCls="icon-add" plain="true" onclick="add" >添加任务</a>
		            </sec:authorize>
		            <sec:authorize url='/call_allocate_import_add.do'>
		            <a class="mini-button" iconCls="icon-upload" plain="true" onclick="importAdd" >批量导入</a>
		            </sec:authorize>
		            <sec:authorize url='/call_allocate_download.do'>
		            <a class="mini-button" iconCls="icon-download" plain="true" href="call_allocate_download.do">下载导入模版</a>
		            </sec:authorize>
		            <sec:authorize url='/call_allocate_export_cur.do'>
		            <span class="separator"></span>
		            <a class="mini-menubutton" iconCls="icon-download" plain="true" menu="#popupMenu1">批量导出</a>
		            </sec:authorize>
		            <sec:authorize url='/call_allocate_find.do'>
		            <span class="separator"></span>
		            <a class="mini-button" iconCls="icon-redo" onclick="onUser" plain="true">批量分配</a>
		            </sec:authorize>
		            <sec:authorize url='/call_allocate_find_platform.do'>
		            <a class="mini-button" iconCls="icon-redo" onclick="onCenter" plain="true">分配到中心</a>
		            </sec:authorize>
		            <sec:authorize url='/call_allocate_find_group.do'>
		            <a class="mini-button" iconCls="icon-redo" onclick="onGroup" plain="true">分配到组</a>
		            </sec:authorize>
		            <sec:authorize url='/dictionary_cm_key_val_view1.do'>
		            <span class="separator"></span>
		            <a class="mini-button" iconCls="icon-reload" onclick="oncategory" plain="true">修改类别</a>
		            </sec:authorize>
		            <sec:authorize url='/call_allocate_del.do'>
		            <span class="separator"></span>
		            <a class="mini-button" iconCls="icon-remove" onclick="remove"  plain="true">批量删除</a>
		            </sec:authorize>
		        </td>
	        </tr>
	    </table>
	</div>
	<ul id="popupMenu1" class="mini-menu" style="display:none;">
        <li iconCls="icon-download" onclick="unaExportCurrent()">导出当前</li>
	    <li iconCls="icon-download" onclick="unaExportAll()">导出全部</li>
    </ul>
    <!-- 话务分配弹窗 -->
	<div id="win1" class="mini-window" allowDrag="false" allowResize="false" showHeader="true" title="话务分配--选择话务员" style="width: 650px;height: 360px;">
	   	 <div style="text-align:center;line-height:23px;padding:5px;">
	         <span>选择中心：</span>    
	         <input emptyText="请选择..." class="mini-combobox" style="width:180px;"
		 		id="call_user_center" showNullItem="true" nullItemText="全部" textField="name" valueField="id" url="" onvaluechanged="loadGroups();"/>
		 	<span style="margin-left: 10px;">选择话务组：</span>
	         <input emptyText="请先选择中心" class="mini-combobox" style="width:180px;"
		 		id="call_user_group" textField="name" valueField="id" url="" onvaluechanged="loadUsers();"/>
	   	 </div>
		<div style="padding-left:5px;padding-right:5px;">
	        <table cellpadding="0" cellspacing="0" >
	            <tr>
	                <td >
	                    <h4 style="margin:0;line-height:22px;font-size:13px;">话务员列表：</h4>
	                    <div id="call_user" class="mini-datagrid" style="width:250px;height:200px;" showPageSize="false" showPageIndex="false"
	                        pagerStyle="padding:2px;" multiSelect="true" url="call_allocate_find_user.do" showReloadButton="false" showPager="false">
	                        <div property="columns">
	                            <div type="checkcolumn" ></div>
	                            <div field="name" width="50" headerAlign="center" >话务员</div>
	                            <div field="lineStatus" width="50" >在线状态</div>
	                        </div>
	                    </div>
	                </td>
	                <td style="padding:5px;">
	           			<input type="button" value="选择" onclick="addSelectedUser()" style="width:50px;"/><br />
	                </td>
	                <td >
	                    <h4 style="margin:0;line-height:22px;font-size:13px;">已选话务员：</h4>
	                    <div id="selectedUser" class="mini-listbox" style="width:200px;height:200px;"              
	                            showCheckBox="true" multiSelect="true" >     
	                        <div property="columns">
	                            <div field="name" width="100" headerAlign="center" >话务员</div>
	                        </div>
	                    </div>                       
	                </td>
	                <td style="padding:5px;">
			            <input type="button" value="删除" onclick="removeUsers()" style="width:55px;margin-bottom:2px;"/><br />                
			            <input type="button" value="清空" onclick="removeAllUsers()" style="width:55px;"/><br />                
	                </td>
	            </tr>
	        </table>
	    </div>
		<div style="text-align:center;padding: 20px;">
			<a class="mini-button" onclick="onOk1" style="">确定</a>
			<a class="mini-button" onclick="onClose1" style="margin-left: 50px;">关闭</a>
		</div>
	</div>
	<!-- 分配到中心弹窗 -->
	<div id="win2" class="mini-window" allowDrag="false" showHeader="true" title="分配到中心--选择中心" style="width: 310px;height: 150px;">
	    <div id="center" emptyText="请选择..." labelField="true" label="中心：" labelStyle="width: 60px;" class="mini-combobox" style="width:250px; margin-left: 15px;margin-top: 10px;" popupWidth="170" textField="name" valueField="id" 
    		url="" multiSelect="true" showClose="true" oncloseclick="onCloseClick" >     
		    <div property="columns">
		    </div>
		</div>
		<div style="text-align:center;padding: 20px;">
			<a class="mini-button" onclick="onOk2" style="">确定</a>
			<a class="mini-button" onclick="onClose2" style="margin-left: 50px;">关闭</a>
		</div>
	</div>
	<!-- 分配到组  -->
	<div id="win3" class="mini-window" allowDrag="false" allowResize="false" showHeader="true" title="分配到组--选择话务组" style="width: 600px;height: 360px;">
    	 <div style="text-align:center;line-height:23px;padding:5px;">
	         <span>选择中心：</span>    
	         <input emptyText="请选择..." showNullItem="true" nullItemText="全部" class="mini-combobox" style="width:200px;"
		 		id="call_center" textField="name" valueField="id" url="" onvaluechanged="loadGroup();"/>
    	 </div>
		<div style="padding-left:5px;padding-right:5px;">
	        <table cellpadding="0" cellspacing="0" >
	            <tr>
	                <td >
	                    <h4 style="margin:0;line-height:22px;font-size:13px;">话务组列表：</h4>
	                    <div id="call_group" class="mini-datagrid" style="width:200px;height:200px;" showPageSize="false" showPageIndex="false"
	                        pagerStyle="padding:2px;" multiSelect="true" url="call_allocate_find_group.do" showReloadButton="false" showPager="false">
	                        <div property="columns">
	                            <div type="checkcolumn" ></div>
	                            <div field="name" width="100" headerAlign="center" >话务组</div>
	                        </div>
	                    </div>
	                </td>
	                <td style="padding:5px;">
	           			<input type="button" value="选择" onclick="addSelected()" style="width:50px;"/><br />
	                </td>
	                <td >
	                    <h4 style="margin:0;line-height:22px;font-size:13px;">已选话务组：</h4>
	                    <div id="selectedGroup" class="mini-listbox" style="width:200px;height:200px;"              
	                            showCheckBox="true" multiSelect="true" >     
	                        <div property="columns">
	                            <div field="name" width="100" headerAlign="center" >话务组</div>    
	                        </div>
	                    </div>                       
	                </td>
	                <td style="padding:5px;">
			            <input type="button" value="删除" onclick="removeSelecteds()" style="width:55px;margin-bottom:2px;"/><br />                
			            <input type="button" value="清空" onclick="removeAllSelecteds()" style="width:55px;"/><br />                
	                </td>
	            </tr>
	        </table>
	    </div>
		<div style="text-align:center;padding: 20px;">
			<a class="mini-button" onclick="onOk3" style="">确定</a>
			<a class="mini-button" onclick="onClose3" style="margin-left: 50px;">关闭</a>
		</div>
	</div>

	<!-- 任务处理修改类别 -->
	<div id="win4" class="mini-window" allowDrag="false" showHeader="true" title="任务处理--修改类别" style="width: 360px;height: 140px;">
	    <input emptyText="请选择..." showNullItem="true" nullItemText="全部" labelField="true" label="任务类别：" labelStyle="width: 80px;" class="mini-combobox" style="width:250px;margin-top: 10px;margin-left: 15px;" id="category" textField="keyValue" valueField="keyName" 
    		url=""/> 
		<div style="text-align:center;padding-bottom: 10px;margin-top: 30px;">
			<a class="mini-button" onclick="onOk4" style="">确定</a>
			<a class="mini-button" onclick="onClose4" style="margin-left: 50px;">关闭</a>
		</div>
	</div>
	<div class="mini-fit" >
		<div id="datagrid1" class="mini-datagrid" onlyCheckSelection="true" multiSelect="true" idField="id" pageSize="20" url="call_allocate_view.do" style="width:100%;height:100%;">
			<div property="columns">
				<div type="indexcolumn"></div>
				<div type="checkcolumn" ></div>
				<div field="serialNum" width="100" allowSort="true"  headerAlign="center" align="center">编号</div>
				<sec:authorize url='/call_manage_my_unt_open.do'>
				<div field="pocessingStatus" width="100" headerAlign="center" renderer="onActionRenderer" align="center">相关操作</div>
				</sec:authorize>
				<div field="categoryValue" width="100" headerAlign="center" align="center">话务类别</div>
				<div field="createTime" width="120" headerAlign="center" align="center" allowSort="true" dateFormat="yyyy-MM-dd HH:mm:ss">创建时间</div>
				<div field="updateTime" width="120" headerAlign="center" align="center" allowSort="true" dateFormat="yyyy-MM-dd HH:mm:ss">更新时间</div>
				<div field="incomingCount" width="60" headerAlign="center" allowSort="true" align="center">呼入次数</div>
				<div field="createUserName" width="60" headerAlign="center" align="center">创建者</div>
				<div field="remark" width="100" headerAlign="center" align="center">备注</div>
				<div field="outsideNum" width="100" headerAlign="center" align="center">外线号码</div>
				<div field="relatedPhone" width="100" headerAlign="center" align="center">相关手机号</div>
			</div>
		</div>
	</div>
<script type="text/javascript">
	mini.parse();
	var grid = mini.get("datagrid1");
	grid.load({listType: 0});
	
	// 打开任务
	function onActionRenderer(e) {
		var record = e.record;
		return '<a href="javascript: openTask('+record._uid+');">打开任务</a>';
	}
	
	function openTask(row_uid) {
		var row = grid.getRowByUID(row_uid);
        mini.open({
            url: "call_manage_my_unt_open.do",
            title: "打开任务", width: 1000, height: 750,
            allowResize: false,
            onload: function () {
                var iframe = this.getIFrameEl();
                var data = { row: row, callStatus: 0 };	// 话务分配列表
                iframe.contentWindow.SetData(data);
            }
        });
	}
	
	// 添加任务
	function add() {
	    mini.open({
	        url: "call_allocate_add.do",
	        title: "新增话务任务", width: 500, height: 300,
	        ondestroy: function (action) {
	        	if(action == 'succ'){
	        		mini.showMessageBox({
	                    title: "提示",
	                    showModal:false,
	                    iconCls: "mini-messagebox-info",
	                    message: "新增话务任务成功！",
	                    timeout: 3000,
	                    x: 'right',
	                    y: 'bottom'
	                });
		            grid.reload();
	        	}
	        }
	    });
	}
	
	// 打开批量导入窗口
	function importAdd(){
    	mini.open({
	        url: "call_allocate_import_add.do",
	        title: "批量导入话务任务", width: 320, height: 280,
	        ondestroy: function (action) {
	        	if(action == 'succ'){
	        		mini.showMessageBox({
	                    title: "提示",
	                    showModal:false,
	                    iconCls: "mini-messagebox-info",
	                    message: "导入成功！",
	                    timeout: 3000,
	                    x: 'right',
	                    y: 'bottom'
	                });
		            grid.reload();
	        	}
	        }
	    });
    }
	
	// 获取批量选择的数据
	function getSelectRows(){
		var rows = grid.getSelecteds();
		var id = [];
		if(rows.length > 0){
			var ids = [];
            for (var i = 0, l = rows.length; i < l; i++) {
                var r = rows[i];
                ids.push(r.id);
            }
            id = ids.join(',');
		}
		return id;
	}
	
	// 批量分配弹窗
	var win1 = mini.get("win1");
	var callUserCenter = mini.get("call_user_center");
	var callUserGroup = mini.get("call_user_group");
	function onUser(e){
		var callIds = getSelectRows();
		if(callIds.length > 0) {
			var el=e.sender.getEl();
			callUserCenter.load("call_allocate_find_platform.do");
			win1.showAtEl(el, {
			   xAlign:"left",
			   yAlign:"below"
			});
		}else {
			mini.alert("未选择任何数据");
		}
	}
	
	function loadGroups() {
		callUser.clearRows();
		callUserGroup.load("call_allocate_find_group.do?centerId=" + callUserCenter.getValue());
	}
	
	var callUser = mini.get("call_user");
	var selectedUser = mini.get("selectedUser");
	function loadUsers() {
		callUser.load({groupId: callUserGroup.getValue()});
	}
	
	function GetUserData() {
        var rows = selectedUser.getData();
        var ids = [], texts = [];
        for (var i = 0, l = rows.length; i < l; i++) {
            var row = rows[i];
            ids.push(row.id);
            texts.push(row.name);
        }

        var data = {};
        data.id = ids.join(",");
        data.text = texts.join(",");
        return data;
    }
	
	function addSelectedUser() {
        var items = callUser.getSelecteds();

        //根据id属性，来甄别要加入选中的记录
        var idField = callUser.getIdField();
        
        //把已选中的数据，用key-value缓存，以便进一步快速匹配
        var idMaps = {};
        var selecteds = selectedUser.getData();
        for (var i = 0, l = selecteds.length; i < l; i++) {
            var o = selecteds[i];
            var id = o[idField];
            idMaps[id] = o;
        }

        //遍历要加入的数组
        for (var i = items.length - 1; i >= 0; i--) {
            var o = items[i];
            var id = o[idField];
            if (idMaps[id] != null) items.removeAt(i);
        }
        callUser.removeRows(items);
        selectedUser.addItems(items);
    }
	
	function removeUsers() {
        var items = selectedUser.getSelecteds();
        selectedUser.removeItems(items);
        callUser.addRows(items);
	}
	
	function removeAllUsers() {
		var selecteds = selectedUser.getData();
		callUser.addRows(selecteds);
        selectedUser.removeAll();
    }
	
	function onOk1() {
		var callIds = getSelectRows();
		var selectedUsers = GetUserData();
		$.post("call_allocate_user.do", {id: callIds, handleUserId: selectedUsers.id}, function(data){
			if(data.success == 'true') {
				mini.showMessageBox({
	                title: "提示",
	                showModal:false,
	                iconCls: "mini-messagebox-info",
	                message: "分配成功！",
	                timeout: 3000,
	                x: 'right',
	                y: 'bottom',
	            });
				grid.reload();
				callUser.clearRows();
				selectedUser.removeAll();
				callUserCenter.setValue("");
				callUserGroup.setValue("");
				win1.hide();
			}else if(data.success == 'error') {
				if(confirm("包含已分配的任务,请重新分配")) {
					grid.reload();
					callUser.clearRows();
					selectedUser.removeAll();
					callUserCenter.setValue("");
					callUserGroup.setValue("");
					win1.hide();
				}
			}else if(data.success == 'false') {
				mini.alert("数据错误（待分配任务id或话务员id不能为空）");
			}
		}, "json");
	}
	
	function onClose1(e){
		callUser.clearRows();
		selectedUser.removeAll();
		callUserCenter.setValue("");
		callUserGroup.setValue("");
		win1.hide();
	}
	
	// 批量分配到中心弹窗
	var win2 = mini.get("win2");
	var centers = mini.get("center");
	function onCenter(e){
		var callIds = getSelectRows();
		if(callIds.length > 0){
			centers.load("call_allocate_find_platform.do");
			var el=e.sender.getEl();
			win2.showAtEl(el, {
			   xAlign:"left",
			   yAlign:"below",
			});
		}else{
			mini.alert("未选择任何数据");
		}
	}

	function onCloseClick(e){
		var obj = e.sender;
        obj.setText("");
        obj.setValue("");
	}
	
	function onOk2(){
		var callIds = getSelectRows();
		var centersId = centers.getValue();
		if(centersId.length > 0){
	 		$.post("call_allocate_center.do", {id: callIds, centerId: centersId}, function(data){
				if(data.success == 'true') {
					win2.hide();
					centers.setValue("");
					mini.showMessageBox({
		                title: "提示",
		                showModal:false,
		                iconCls: "mini-messagebox-info",
		                message: "分配成功！",
		                timeout: 3000,
		                x: 'right',
		                y: 'bottom'
		            });
					grid.reload();
				}else if(data.success == 'error') {
					if(confirm("包含已分配的任务,请重新分配")) {
						win2.hide();
						centers.setValue("");
						mini.alert("包含已分配的任务,请重新分配");
						grid.reload();
					}
				}else if(data.success == 'false') {
					mini.alert("分配失败（话务任务或中心id不能为空）");
				}
			}, "json");
		}else{
			mini.alert("请选择中心");
		}
	}
	
	function onClose2(e){
		centers.setValue("");
		win2.hide();
	}
	
	// 批量分配到组弹窗
	var win3 = mini.get("win3");
	var callCenters = mini.get("call_center");
	function onGroup(e){
		var callIds = getSelectRows();
		if(callIds.length > 0) {
			callCenters.load("call_allocate_find_platform.do");
			var el=e.sender.getEl();
			win3.showAtEl(el, {
			   xAlign:"left",
			   yAlign:"below"
			});
		}else {
			mini.alert("未选择任何数据");
		}
	}
	
	var callGroup = mini.get("call_group");
	var selectedGroup = mini.get("selectedGroup");
	function loadGroup() {
		callGroup.load({centerId: callCenters.getValue()});
	}
	
	function GetData() {
        var rows = selectedGroup.getData();
        var ids = [], texts = [];
        for (var i = 0, l = rows.length; i < l; i++) {
            var row = rows[i];
            ids.push(row.id);
            texts.push(row.name);
        }

        var data = {};
        data.id = ids.join(",");
        data.text = texts.join(",");
        return data;
    }
	
	function addSelected() {
        var items = callGroup.getSelecteds();

        //根据id属性，来甄别要加入选中的记录
        var idField = callGroup.getIdField();

        //把已选中的数据，用key-value缓存，以便进一步快速匹配
        var idMaps = {};
        var selecteds = selectedGroup.getData();
        for (var i = 0, l = selecteds.length; i < l; i++) {
            var o = selecteds[i];
            var id = o[idField];
            idMaps[id] = o;
        }

        //遍历要加入的数组
        for (var i = items.length - 1; i >= 0; i--) {
            var o = items[i];
            var id = o[idField];
            if (idMaps[id] != null) items.removeAt(i);
        }
        selectedGroup.addItems(items);
    }
	
	function removeSelecteds() {
        var items = selectedGroup.getSelecteds();
        selectedGroup.removeItems(items);
    }
	
	function removeAllSelecteds() {
        selectedGroup.removeAll();
    }
	
	function onOk3() {
		var callIds = getSelectRows();
		var selectedGroups = GetData();
		$.post("call_allocate_group.do", {id: callIds, groupId: selectedGroups.id}, function(data){
			if(data.success == 'true') {
				mini.showMessageBox({
	                title: "提示",
	                showModal:false,
	                iconCls: "mini-messagebox-info",
	                message: "分配成功！",
	                timeout: 3000,
	                x: 'right',
	                y: 'bottom',
	            });
				grid.reload();
				win3.hide();
				callGroup.clearRows();
				selectedGroup.removeAll();
				callCenters.setValue("");
			}else if(data.success == 'error') {
				if(confirm("包含已分配的任务,请重新分配")) {
					grid.reload();
					win3.hide();
					callGroup.clearRows();
					selectedGroup.removeAll();
					callCenters.setValue("");
				}
			}else if(data.success == 'false') {
				mini.alert("数据错误（待分配任务或话务组id不能为空）");
			};
		}, "json");
	}
	
	function onClose3(e){
		win3.hide();
		callGroup.clearRows();
		selectedGroup.removeAll();
		callCenters.setValue("");
	}
	
	// 批量删除
	function remove(){
		var id = getSelectRows();
        if (id.length > 0) {
            if (confirm("确定删除选中记录？")) {
                grid.loading("操作中，请稍后......");
                $.ajax({
                    url: "call_allocate_del.do?id=" +id,
                    dataType: "json",
                    success: function (text) {
                   		if(text.success){
                    		mini.showMessageBox({
        	                    title: "提示",
        	                    showModal:false,
        	                    iconCls: "mini-messagebox-info",
        	                    message: "删除成功！",
        	                    timeout: 3000,
        	                    x: 'right',
        	                    y: 'bottom'
        	                });
                   		}else{
                   			mini.alert("删除失败，id不能为空。");
                   		}
                        grid.reload();
                    }
                });
            }
        } else {
            mini.alert("请选中一条记录");
        }
	}
	
	// 批量修改类别	
	var win4 = mini.get("win4");
	var category = mini.get("category");
	function oncategory(e){
		var el=e.sender.getEl();
		var callIds = getSelectRows();
		if(callIds.length > 0){
			category.load("dictionary_cm_key_val_view.do?typeName=CALL_TASK_TYPE");
			win4.showAtEl(el, {
			   xAlign:"left",
			   yAlign:"below"
			});
		}else {
			mini.alert("未选择任何数据");
		}
	}
	
	function onOk4(){
		var callIds = getSelectRows();
		var categoryKey = category.getValue();
		if(categoryKey.length > 0){
			$.post("call_allocate_cat.do", {id: callIds, category: categoryKey}, function(data){
				if(data.success){
					win4.hide();
					category.setValue("");
					mini.showMessageBox({
		                title: "提示",
		                showModal:false,
		                iconCls: "mini-messagebox-info",
		                message: "修改成功！",
		                timeout: 3000,
		                x: 'right',
		                y: 'bottom'
		            });
					grid.reload();
				}else{
					mini.alert("修改失败（任务id或类别为空）");
				}
			}, "json");
		}else{
			mini.alert("未选择类别");
		}
	}
	
	function onClose4(){
		category.setValue("");
		win4.hide();
	}
	
	//批量导出全部
	function unaExportAll(){
		var c1 = mini.get("create_time").getFormValue();
		var c2 = mini.get("end_time").getFormValue();
		var u1 = mini.get("u_stime").getFormValue();
		var u2 = mini.get("u_etime").getFormValue();
		var serialNum = mini.get("serialNum").getFormValue();
		var category = mini.get("s_category").getFormValue();
		var relatedPhone = mini.get("s_relatedPhone").getFormValue();
		var outsideNum = mini.get("s_outsideNum").getFormValue();
		location.href="call_allocate_export_all.do?stime="+c1+"&etime="+c2+"&listType="+"0"
				+"&serialNum="+serialNum+"&category="+category+"&relatedPhone="+relatedPhone
				+"&outsideNum="+outsideNum+"&ustime"+u1+"&uetime"+u2;
	}
	//批量导出当前页
	function unaExportCurrent(){
		var data = grid.data;
        var ids = [];
        $.each(data , function(){
            ids.push(this.id);
        });
        var id = ids.join(',');
        if(id) {
        	location.href="call_allocate_export_cur.do?id=" +id;
        }
	}
	
	function search() {
		var c1 = mini.get("create_time").getFormValue();
		var c2 = mini.get("end_time").getFormValue();
		var u1 = mini.get("u_stime").getFormValue();
		var u2 = mini.get("u_etime").getFormValue();
		var serialNum = mini.get("serialNum").getFormValue();
		var category = mini.get("s_category").getFormValue();
		var relatedPhone = mini.get("s_relatedPhone").getFormValue();
		var outsideNum = mini.get("s_outsideNum").getFormValue();
		grid.load({stime:c1,etime:c2,serialNum:serialNum,category:category,relatedPhone:relatedPhone,outsideNum:outsideNum,ustime:u1,uetime:u2,listType:0});
	}
	
	function showHq(){
		var splitter1 = mini.get("splitter1");
		$("#splitter1").css("height","140px");
		splitter1.showPane("2");
	}

	function hideHq(){
		var splitter1 = mini.get("splitter1");
		$("#splitter1").css("height","70px");
		splitter1.hidePane("2");
	}
</script>
</body>
</html>